Why does adding DP to my recursion make it stop working correctly

visit shbcf.ru